/// @tags:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 5e5 + 1, maxm = 5e5 + 1, maxe = maxm * 2 + maxn, maxx = 1e5 + 5,
              mod = 998244353;

int ecnt;
int heads[maxm + maxn], in[maxm + maxn];

struct Edge {
  int v, nxt;
} e[maxe];

inline void add(int u, int v) { e[++ecnt].v = v, e[ecnt].nxt = heads[u], heads[u] = ecnt, in[v]++; }

int n, m;
int x[maxn];

struct Segment {
  int l, r, h;
  bool operator<(const Segment &rhs) const { return h < rhs.h; }
} seg[maxm];

int val[maxx * 4], lazy[maxx * 4];

void push_down(int cur) {
  int ls = cur << 1, rs = cur << 1 | 1;
  lazy[ls] = lazy[cur];
  val[ls] = lazy[cur];
  lazy[rs] = lazy[cur];
  val[rs] = lazy[cur];
  lazy[cur] = -1;
}

void modify(int cur, int l, int r, int L, int R, int v) {
  if (L <= l && r <= R) {
    val[cur] = v, lazy[cur] = v;
    return;
  }
  if (lazy[cur] != -1) push_down(cur);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(cur << 1, l, mid, L, R, v);
  if (R > mid) modify(cur << 1 | 1, mid + 1, r, L, R, v);
}

int query(int cur, int l, int r, int pos) {
  if (l == r) return val[cur];
  int mid = (l + r) >> 1;
  if (lazy[cur] != -1) push_down(cur);
  if (pos <= mid) return query(cur << 1, l, mid, pos);
  return query(cur << 1 | 1, mid + 1, r, pos);
}

int sum[maxm + maxn];

std::queue<int> q;

void topu() {
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      sum[v] += sum[u];
      sum[v] %= mod;
      if (--in[v] == 0) q.push(v);
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> seg[i].l >> seg[i].r >> seg[i].h;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> x[i];
  }
  memset(lazy, -1, sizeof(lazy));
  modify(1, 0, maxx, 0, maxx, 0);
  std::sort(seg + 1, seg + m + 1);
  std::stack<int> stk;
  for (int i = 1; i <= m; ++i) {
    add(i, query(1, 0, maxx, seg[i].l));
    add(i, query(1, 0, maxx, seg[i].r));
    stk.push(i);
    modify(1, 0, maxx, seg[i].l, seg[i].r, i);
  }
  for (int i = 1; i <= n; ++i) {
    add(m + i, query(1, 0, maxx, x[i]));
    sum[m + i] = 1;
  }
  for (int i = 0; i <= n + m; ++i)
    if (in[i] == 0) q.push(i);
  topu();
  cout << sum[0];
  return 0;
}
}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("T2.in", "r", stdin);
  freopen("T2.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
